﻿using Microsoft.AspNetCore.Mvc;

namespace FEShop.AppUserService.Controllers
{
    /// <summary>
    /// 用户信息管理
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class AppUserController : ControllerBase
    {
        private readonly ILogger<AppUserController> _logger;
        private readonly IConfiguration _configuration;

        public AppUserController(ILogger<AppUserController> logger, IConfiguration configuration)
        {
            _logger = logger;
            _configuration = configuration;
        }

        /// <summary>
        /// 数据库迁移
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> TestConnAsync()
        {

            #region 数据迁移 
            // 注册 SqlSugar
            var conn = _configuration.GetSection("ConnectionStrings:FullCtrlConnection").Value;

            Console.WriteLine($"连接字符串: {conn}");
            Console.WriteLine("==============================");
            var sqlSugar = new AppUserDbContext(_configuration);
            //执行数据迁移,等待Jenkins中数据库初始化脚本执行完成。
            sqlSugar.InitTabls();
            #endregion
            return Ok("完成数据库迁移！！!");
        }

    }
}
